<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/View.php');

Class UserView extends BaseView
{
	function UserView()
	{
		parent::BaseView();
	}

	function ShowLoginForm(&$user, $message='')
	{
		$this->output  = '<div id="UserLogin">';
		$this->output .= '<h2>Gebruiker Aanmelden</h2>';
		$this->output .= '<form method="post" action="'.$_SERVER['SCRIPT_NAME'].'">';
		
		$this->output .= '<table class="form">';
		
		// Message
		if ($message!='')
		{
			$this->output .= '<tr><td colspan="2" class="formWarning">'.$message.'</td>';
		}
		
		// E-mail
		$this->output .= '<tr><td class="formFieldLabel"><label for="loginEmail">E-mail:</label></td>';
		$this->output .= '<td class="formFieldEntry"><input type="text" id="loginEmail" name="loginEmail" maxlength="50" size="25" /></td></tr>';
		
		// Password
		$this->output .= '<tr><td class="formFieldLabel"><label for="loginPassword">Password:</label></td>';
		$this->output .= '<td class="formFieldEntry"><input type="password" id="loginPassword" name="loginPassword" maxlength="50" size="25" /></td></tr>';
		
		// Submit
		$this->output .= '<tr><td>&nbsp;</td><td class="formAction"><input type="hidden" name="formID" value="' . sha1(session_id()) . '" />';
		$this->output .= '<input type="submit" id="btnSubmit" name="btnSubmit" value="Login" /></td></tr>';

		$this->output .= '</table>';
		$this->output .= '</form>';
		$this->output .= '</div>';
	}

	function ShowLogoutForm(&$user)
	{
		//$this->output = utf8_encode($content->Content);
	}

	function ShowProfile(&$user, $justLoggedin=false)
	{
		$this->output  = '<div id="UserProfile">';
		$this->output .= '<h2>Gebruikersprofiel</h2>';
		if ($justLoggedin)
		{
			$this->output .= '<script language="javascript" type="text/javascript" src="/WebCMS/assets/WebCMS.js"></script>'."\n";
		}
		$this->output .= $user->FirstName . ' ' . $user->LastName . ' ';
		$this->output .= '(<a href="mailto:' . $user->Email . '">' . $user->Email . '</a>)<br />';
		$this->output .= '<a href="/user/logout">Log out</a>';
		$this->output .= '<ul>';
		$this->output .= '<li><a href="/">Website Home</a></li>';
		$this->output .= '<li><a href="/admin/console" >Management Console</a></li>';
		$this->output .= '<li><a href="javascript:void(0);" onclick="ShowManagementConsole()">Management Console</a> (nieuw venster)</li>';
		$this->output .= '</ul>';
		$this->output .= '</div>';
		//$this->output = utf8_encode($content->Content);
	}

	function ShowSignUpForm(&$user)
	{
		//$this->output = utf8_encode($content->Content);
	}

	function ShowLoginLink()
	{
		$this->output  = '<div id="UserLogin">';
		$this->output .= '<a href="./login">Hier inloggen</a>';
		$this->output .= '</div>';
	}
}
?>